#include"com.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include<fcntl.h>
#include<cstring>
#include<stdio.h>
#include<cassert>
#include<unistd.h>

int main()
{
    int wfd = open(fifoname.c_str(),O_WRONLY);
    cout<<wfd<<endl;

    if(wfd < 0)
    {
        cout<<"errno:"<<errno<<":"<<strerror(errno)<<endl;
        return 1;
    }

    char buffer[NUM];
    while(1)
    {
        cout<<"输入你的信息"<<endl;
        char* mes = fgets(buffer,sizeof(buffer),stdin);
        assert(mes);
        (void)mes;

        buffer[strlen(buffer)-1] = 0 ;
        if(strcasecmp(buffer,"quit") == 0) break;

        ssize_t n = write(wfd,buffer,sizeof(buffer));
        assert( n> 0);
        (void)n;
    }

    close(wfd);

    return 0;
}